﻿j.C.AutoHideTopAd = new j.Class().extend({
    option: {
        box: null, //保存广告的ID
        show: 5000, //显示的时间
        height: 50,
        width: "100%"
    }, //全局默认值。
    __timer: 0,
    initialize: function(box, cookieName, options) {
        this.box = j.$(box);
        this.cookieName = cookieName;
        this.SetOption(options);
        this.box.style.display = "none";
        if (j.getcookie(this.cookieName) != "closed")
            j.addEventHandler(window, "load", j.BindAsEventListener(this, function() { this.display(1); }));
    },
    display: function(type) {
        if (type) {
            $("#" + this.box.id).slideDown(1000);
            //this.box.style.display = "";
            this.__timer = window.setTimeout(j.BindAsEventListener(this, function() { this.display(0); }), this.option.show);
        }
        else {
            if (this.__timer > 0)
                window.clearTimeout(this.__timer);
            $("#" + this.box.id).slideUp(1000);
            j.setcookie(this.cookieName, "closed");
            this.box.style.display = "none";

        }
    }
});